<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>审批解除帮教编辑</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <style>
        .discell{
            text-align: right;
            width: 100px;
        }

        .input{
            width: 200px;
        }
    </style>
</head>
<body>
<form id="form1" method="post" style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;">
    <!-- 编辑框START-->
    <div id="editform" class="form" style="padding:10px;">
        <input name="id" class="mini-hidden" style="width: 100%;" />
        <input name="create_user" class="mini-hidden" style="width: 100%;" value="${create_user!''}"/>
        <input name="clab" class="mini-hidden" style="width: 100%;" value="${clab!''}"/>
        <input name="clab_name" class="mini-hidden"  style="width: 100%;" value="${clab_name!''}"/>
        <input name="orgid" class="mini-hidden"  style="width: 100%;" value="${orgid!''}"/>
        <input name="priNum" id="priNum" class="mini-hidden"  style="width: 100%;" />
        <input name="jieChuAutoDate" id="jieChuAutoDate" class="mini-hidden"  style="width: 100%;" value="${jieChuAutoDate!''}" />
        <table class="form-table" align="center" style="margin-left: -14px;" cellspacing="8">
            <tr>
                <td class="discell"><font color="#dc143c">*</font>姓名:</td>
                <td >
                    <input name="pname" id="pname" class="mini-textbox" style="width: 200px" />
                </td>

                <td class="discell"><font color="#dc143c">*</font>性别:</td>
                <td>
                    <input name="sex" id="sex" class="mini-textbox" style="width: 200px"/>
                </td>
            </tr>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>身份证号:</td>
                <td >
                    <input name="idnum" id="idnum" class="mini-textbox" style="width: 200px" />
                </td>

                <td class="discell"><font color="#dc143c">*</font>出生日期:</td>
                <td>
                    <input name="birthday" id="birthday" class="mini-datepicker" style="width: 200px" />
                </td>
            </tr>
            <tr>
                <td class="discell">户籍地址:</td>
                <td colspan="3">
                    <input class="mini-textbox"  style="width: 100%"  id="nativeName" name="nativeName"/>
                </td>
            </tr>
            <tr>
                <td class="discell">解除时间:</td>
                <td class="input">
                    <input name="releaseDate"  id="releaseDate" style="width: 200px" class="mini-datepicker" emptyText = "解除时间" />
                </td>
                <td class="discell"><font color="#dc143c">*</font>解除原因:</td>
                <td>
                    <input name="releaseReason"  id="releaseReason" class="mini-combobox" style="width: 200px"
                           textField="codeName" valueField="codeId" emptyText="请选择..."
                           url="/azbj/shzzgl/socialOrgInfo/getComboboxData?codeType=3_10"/>
                </td>
            </tr>
            <tr>
                <td class="discell">解除总结:</td>
                <td colspan="3">
                    <input class="mini-textarea"  style="width: 100%;height: 100px;" emptyText = "请输入解除总结" id="releaseRemark" name="releaseRemark" required="true"/>
                </td>
            </tr>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>审批状态:</td>
                <td class="input">
                    <input name="spzt" id="spzt" class="mini-radiobuttonlist" required="true"
                           data="[{ id: 3, name: '同意' },{ id: 4, name: '不同意' }]"
                           textField="name" valueField="id" onValueChanged="spztChange()"/>
                </td>
            </tr>
            <tr id="check">
                <td class="discell"><font color="#dc143c">*</font>审核备注:</td>
                <td colspan="3">
                    <input class="mini-textarea"  style="width: 100%;height: 100px;" emptyText = "请输入审核备注" id="failurContent" name="failurContent" required="true"/>
                </td>
            </tr>
        </table>
    </div>
    <!--编辑框END-->
    <div style="padding:2px;margin: 0 auto;text-align: center" >
        <a class="mini-button" iconCls="fa-save" plain="true" onclick="saveData()" >保存</a>
        <a class="mini-button" iconCls="fa-close" plain="true" onclick="onCancel()" >关闭</a>
    </div>
</form>

<script type="text/javascript">
    mini.parse();
    $("#check").css("display","none");
    var form = new mini.Form("form1");

    var clab_name = mini.getByName("clab_name").getValue();
    var create_user = mini.getByName("create_user").getValue();
    var clab = mini.getByName("clab").getValue();
    var orgid = mini.getByName("orgid").getValue();
    var priNum = mini.getByName("priNum");
    var id = mini.getByName("id");
    var failurContent=mini.getbyName("failurContent");
    //得到解除日期对象
    var jieChuAutoDate = mini.getByName("jieChuAutoDate");

    //标准方法接口定义
    function SetData(data) {
        if (data.pname) {
            mini.get("pname").setEnabled(false);
            mini.get("sex").setEnabled(false);
            mini.get("birthday").setEnabled(false);
            mini.get("idnum").setEnabled(false);
            mini.get("nativeName").setEnabled(false);
        }
        if(data.releaseDate){
            mini.get("releaseDate").setEnabled(false);
            mini.get("releaseReason").setEnabled(false);
            mini.get("releaseRemark").setEnabled(false);
        }
        if(data.spzt==3 || data.spzt==4){
            mini.get("spzt").setEnabled(false);
            $("#auditingbtn").attr("style","display:none;");
        }
        data.sex=onGetGenderName(data.sex);
        data.birthday=onYearMonthDayDateRenderer(data.birthday);
        //如果是期满解除---给解除时间赋上值 -- 其实可以直接将库中的真实时间拿出来用的
        if (data.releaseReason == '1') {
            data.releaseDate = jieChuAutoDate.getValue();
            //并且将解除时间变成灰色只读状态
            mini.get("releaseDate").setEnabled(false);
        } else {
            //如果不是期满解除--就将自己手动输入的日期反显出来
            data.releaseDate = data.releaseDate1;
        }
        var o = mini.decode(data);
        form.setData(o);
        form.setChanged(false);
        priNum.setValue(data.priNum);
        id.setValue(data.id);
        failurContent.setValue("");
    }

    function saveData() {
        //验证非空字段
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        var data = form.getData();
        var spzt = data.spzt;
        if(spzt ==2) {
            mini.alert("请选择审批状态！")
            return;
        }

        //设置基础参数值
        data.update_user=create_user;

        var json = mini.encode(data);
        commonSaveData("/azbj/jcbjgl/auditingReleaseHelpEdu/save", {data: json}, callback);
        // 保存成功的回调函数
        function callback() {
            mini.alert("保存成功","成功",window.CloseOwnerWindow);
        }
    }

    //性别code转换
    function onGetGenderName(e) {
        var gender = e;
        if(gender==1){
            return "男性";
        } else if(gender==2){
            return "女性";
        } else if(gender==0){
            return "未知的性别";
        } else if(gender==9){
            return "未说明的性别";
        }
    }

    //追加审核失败原因输入框
    function spztChange() {
        var spzt=mini.get("spzt").getValue();
        if(spzt==4){
            $("#check").css("display","table-row");
        }else{
            $("#check").css("display","none");
        }

    }
    //日期转换为年月日
    function onYearMonthDayDateRenderer(e){
        var date = new Date(e);
        var Y = date.getFullYear() + '-';
        var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
        var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
        var formatTime = Y + M + D ;
        return formatTime;
    }
</script>
</body>
</html>